package com.web.servlet;

import com.fullstuck.service.impl.PigServiceimpl;
import org.springframework.context.ApplicationContext;
import org.springframework.ui.context.support.UiApplicationContextUtils;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Index extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
        PigServiceimpl bean = context.getBean(PigServiceimpl.class);
        bean.dopig_eat();
    }

    @Override
    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
